package com.ls.controller.holiday;

import cn.dev33.satoken.stp.StpUtil;
import com.ls.controller.holiday.model.AddHolidayModel;
import com.ls.controller.holiday.model.EditHolidayModel;
import com.ls.service.IHolidayService;
import com.ls.utils.ResultData;
import io.swagger.annotations.Api;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

import static com.ls.constant.SystemConstants.*;

/**
 * @ClassName HolidayController
 * @Description 节假日
 *
 * @author pengyu
 * @since 2024-06-28
 */
@Api(value = "节假日", tags = "节假日")
@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/holiday")
public class HolidayController {
    private final IHolidayService service;

    /** 新增节假日  */
    @PostMapping("add")
    public ResultData add(@Valid @RequestBody AddHolidayModel model) {
        model.setCustomerId((long) NUMBER_0);
        model.setPeriod(REPEAT_CYCLE_YEAR);
        model.setPeriodCount(NUMBER_1);
        return service.add(model);
    }
    /** 更新节假日  */
    @PostMapping("edit")
    public ResultData edit(@Valid @RequestBody EditHolidayModel model) {
        model.setCustomerId((long) NUMBER_0);
        model.setPeriod(REPEAT_CYCLE_YEAR);
        model.setPeriodCount(NUMBER_1);
        return service.edit(model);
    }

    /** 删除节假日 */
    @PostMapping("del")
    public ResultData del(@RequestParam Long holidayId) {
        return service.del(holidayId);
    }

    /** 查询节假日 */
    @GetMapping("getPaging")
    public ResultData getHoliday(Long customerId, Long categoryId,Integer showBirth,Integer showExist,Integer categoryType) {
        return service.getHoliday(categoryId,customerId,showBirth,showExist,categoryType);
    }
}
